package com.news.views;

import com.news.R;
import com.news.model.NewsDetail;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class NewsContentView extends RelativeLayout {

	private ImageView image;
	private TextView title;
	private TextView update;
	private TextView body;

	public NewsContentView(Context context) {
		super(context);
		init(context);
		
	}
	
	/**
	 * Creates a SimpleTextField Widget with a defined Style.
	 * @param context
	 * @param attrs
	 */
	public NewsContentView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}

	/**
	 * Creates a SimpleTextField Widget with a defined Style and a defined style.
	 * @param context
	 * @param attrs
	 * @param defStyle
	 */
	public NewsContentView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init(context);
	}

	private void init(Context context) {
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		ViewGroup inflated = (ViewGroup) inflater.inflate(R.layout.body_news, null);
		this.addView(inflated);
		image = (ImageView) findViewById(R.id.image_new);
	
		title = (TextView) findViewById(R.id.title_new);
		body = (TextView)findViewById (R.id.body_new);
		
	}
	
	public void setBody(String text){
		this.body.setText(text);
	}
	
	public void setTitle(String text){
		this.title.setText(text);
	}
	
	public void setImage(int idImg){
		this.image.setImageResource(idImg);
	}
	
	public void setDataUpdated(String text){
		this.update.setText(text);
	}
	
	public void setInfo(NewsDetail item){
		setTitle(item.getTitle());
		setImage(item.getImage());
		setBody(item.getDetail());
	}
	
}
